package liquidfs.data;

import com.thoughtworks.xstream.annotations.*;

@XStreamAlias("device")
public class PeerDevice implements Comparable<PeerDevice> {

   @XStreamAsAttribute()
	private String id;
   
   @XStreamAsAttribute()
	private String name;
	
	public PeerDevice(String id, String name) {
		this.id = id;
		this.name = name;
	}
	
	public String getID() {
		return id;
	}
	
	public String getName() {
		return name;
	}
	
	public void setName (String name) {
		this.name = name;
	}
	
	@Override
	public int hashCode () {
	   return this.id.hashCode();
	}
	
	@Override
	public boolean equals (Object o) {
	   if (o instanceof PeerDevice) {
	      return ((PeerDevice)o).id.equals(this.id);
	   }
	   
	   return false;
	}

   @Override
   public int compareTo(PeerDevice o) {
      return this.id.compareTo(o.id);
   }
   
   @Override
   public String toString () {
      return this.name + " (" + this.id + ")";
   }
}
